package me.healthcare.activity;

import me.healthcare.app.R;
import me.healthcare.common.ActionBarUtils;
import me.healthcare.common.MessageAdapter;
import me.healthcare.common.PatientAdapter;
import me.healthcare.mocktest.Doctor_Mock;
import me.healthcare.mocktest.Message_Mock;
import me.healthcare.model.Doctor;
import me.healthcare.model.Message;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class DoctorActivity extends Activity {
	// views
	private TextView doctor_name;
	private TextView doctor_birthday;
	private TextView doctor_sex;
	private TextView doctor_active_code;
	private TextView doctor_specialist;
	private TextView doctor_email;

	private TextView show_thongbao_link;
	private TextView chat_list_label;
	private TextView patient_list_label;
	private ListView listView1;
	private LinearLayout linear_graph;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.doctor_screen);

		// init actionbar
		ActionBarUtils.remade(this,
				getResources().getString(R.string.activity_doctor));

		loadViews();

		show_thongbao_link.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO
				Toast.makeText(DoctorActivity.this, "Hiện chưa có o(╥﹏╥)o",
						Toast.LENGTH_SHORT).show();
			}
		});

		chat_list_label.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				chat_list_label
						.setBackgroundResource(R.drawable.switch_cell_selected);
				chat_list_label.setTextColor(getResources().getColor(
						R.color.white));

				patient_list_label
						.setBackgroundResource(R.drawable.switch_cell_notselected);
				patient_list_label.setTextColor(getResources().getColor(
						R.color.blue_caption));
				linear_graph.removeAllViews();

				// TODO
				Message[] message_data = Message_Mock.getMessageData(30);
				MessageAdapter adapter = new MessageAdapter(
						DoctorActivity.this, R.layout.message_row, message_data);

				listView1 = new ListView(DoctorActivity.this);
				listView1.setAdapter(adapter);
				linear_graph.addView(listView1);
			}
		});

		patient_list_label.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				patient_list_label
						.setBackgroundResource(R.drawable.switch_cell_selected);
				patient_list_label.setTextColor(getResources().getColor(
						R.color.white));

				chat_list_label
						.setBackgroundResource(R.drawable.switch_cell_notselected);
				chat_list_label.setTextColor(getResources().getColor(
						R.color.blue_caption));
				linear_graph.removeAllViews();

				// TODO
				Message[] message_data = Message_Mock.getMessageData(30);
				PatientAdapter adapter = new PatientAdapter(
						DoctorActivity.this, R.layout.simple_row, message_data);

				listView1 = new ListView(DoctorActivity.this);
				listView1.setAdapter(adapter);
				linear_graph.addView(listView1);
			}
		});

		chat_list_label.performClick();

		// TODO
		Doctor doctor = Doctor_Mock.getDoctor();

		doctor_name.setText(doctor.getFullname());
		doctor_birthday.setText(doctor.getBirthday());
		doctor_sex.setText(doctor.getSex());
		doctor_active_code.setText(doctor.getId());
		doctor_specialist.setText(doctor.getGoodAt());
		doctor_email.setText(doctor.getEmail());

	}

	private void loadViews() {
		// info textview
		doctor_name = (TextView) findViewById(R.id.doctor_name);
		doctor_birthday = (TextView) findViewById(R.id.doctor_birthday);
		doctor_sex = (TextView) findViewById(R.id.doctor_sex);
		doctor_active_code = (TextView) findViewById(R.id.doctor_active_code);
		doctor_specialist = (TextView) findViewById(R.id.doctor_specialist);
		doctor_email = (TextView) findViewById(R.id.doctor_email);

		// graph textview
		chat_list_label = (TextView) findViewById(R.id.chat_list_label);
		patient_list_label = (TextView) findViewById(R.id.patient_list_label);
		show_thongbao_link = (TextView) findViewById(R.id.show_thongbao_link);
		// layout
		linear_graph = (LinearLayout) findViewById(R.id.linear_graph);

		listView1 = (ListView) findViewById(R.id.list_view);
	}
}
